import numpy as np
import csv

def load_data_csv(file):
	lines = csv.reader(open(file))
	data = []
	for line in lines:
		data.append(line)
	data=np.asarray(data)
	return data

name=['task2_pre_7473.csv', 'task2_pre_7464.csv' ,'task2_pre_7391.csv', 'task2_pre_c4.csv']#,'task2_pre_c2.csv', 'task2_pre_c3.csv']

ret=[]
for n in name:
	a=load_data_csv(n)
	ret.append(a[:,1])
ret=np.transpose(np.asarray(ret).astype(int))

pp=[]
for r in ret:
	a=[0,0,0]
	for v in r:
		a[v]+=1
	#if np.argmax(np.asarray(a)) == 0 and a[0] == 1:
	#	print a
	pp.append(np.argmax(np.asarray(a)))

k=1
f = open("task2_pre_merge.csv", "w")
for p in pp:
	print >> f,"%d,%d" %(k,p)
	k += 1
f.close()